package com.example.demo.configuration.aspect;

import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import java.util.Arrays;

/**
 * @description:
 * @author: cj
 * @create: 11-01-12 11:05:51
 */
@Slf4j
@Aspect
@Configuration
public class AspectConfig {

//    @Around("@annotation(com.example.demo.entity.note.NotNull)")
//    public Object around(ProceedingJoinPoint pjp) {
//        log.info( "切面：" + pjp );
//        Object[] args = pjp.getArgs();
//        log.info( "参数列表：" + args );
//        return null;
//    }

//    @Pointcut("execution(public * com.example.demo..*.*.*(..))")
//    public void pointCutMethod() {
//    }
//
//    @Around("pointCutMethod()")
//    public Object doAround(ProceedingJoinPoint pjp) throws Throwable {
//        String controller = pjp.getTarget().getClass().getSimpleName();
//        String method = pjp.getSignature().getName();
//        String args = Arrays.toString( pjp.getArgs() );
//        log.info( "<{}.{}>,请求参数:{}", controller, method, args );
//        Object ret = pjp.proceed();
//        log.info( "响应数据:{}", JSON.toJSONString( ret ) );
//        return ret;
//    }

}
